package com.hp.util;
import java.util.List;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;

public class PropUtil {
	
	public static String getPropByKey(String confName,String prop){
		Properties ppts = new Properties();
		InputStream stream =null;

		stream =PropUtil.class.getResourceAsStream("/config/"+confName+".properties"); 
				//PropUtil.class.getResourceAsStream("/config/"+confName+".properties");//获取具体配置文件

		try {
			ppts.load(stream);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ppts.getProperty(prop);
	}
	
	
	
	@SuppressWarnings("unchecked")
	public static Map<String, String> getAllProp(String confName){
		Properties ppts = new Properties();
		InputStream stream =null;

		stream =PropUtil.class.getResourceAsStream("/config/"+confName+".properties"); 
				//PropUtil.class.getResourceAsStream("/config/"+confName+".properties");//获取具体配置文件

		try {
			ppts.load(stream);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Map<String,String> all = new HashMap<String, String>();
		List<Map<String,String>> list = new ArrayList<Map<String,String>>();
		for(Entry<Object, Object> key:ppts.entrySet()){
			all.put((String)key.getKey(),(String)key.getValue() );
		}
		
		return all;
	}
}
